package com.feihong.txgw.utils.weakrefrence;

import android.app.Activity;

import java.lang.ref.WeakReference;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName StackTopActivity
 * @package com.feihong.txgw.utils.weakrefrence
 * @data 2018/6/14 16:54
 * @Describe  栈顶activity
 * @Change
 */
public class StackTopActivity {

    private static StackTopActivity stackTopActivity = new StackTopActivity();

    private WeakReference<Activity> weakReference;
    private StackTopActivity(){

    }

    public static StackTopActivity getInstance(){
        return stackTopActivity;
    }

    public void put(Activity activity){
        weakReference = new WeakReference<>(activity);
    }

    public Activity get(){
        if(weakReference != null){
            return weakReference.get();
        }
        return null;
    }
}
